package com.bestillet.kyllingogco;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class OptionArrayAdapter extends ArrayAdapter<Option> {
	private ArrayList<Option> options;
	
	private Activity context;
	
	public OptionArrayAdapter(Context context, ArrayList<Option> options) {
		super(context, R.layout.option_item, options);
		this.context = (Activity) context;
		this.options = options;
	}

	static class ViewHolder {
		protected TextView name;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = null;
		if (convertView == null) {
			LayoutInflater inflator = context.getLayoutInflater();
			view = inflator.inflate(R.layout.option_item, parent, false);
			final ViewHolder viewHolder = new ViewHolder();
			
			viewHolder.name = (TextView) view.findViewById(R.id.lblOptionName);
			view.setTag(viewHolder);
		} else {
			view = convertView;
		}
		
		ViewHolder holder = (ViewHolder) view.getTag();
		holder.name.setText(options.get(position).getFill());
		return view;
	}
}